package com.mogen.app.dentistry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mogen.app.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class ActivityView2 extends Activity {

    private ListView mListViewMenu;
    private ViewGroup mLayoutCondition;
    private WebView mWebViewContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main2);
	initControls();
    }

    private void initControls() {
	mListViewMenu = (ListView) findViewById(R.id.main2_lst_menu1);

	List<Map<String, String>> datasource = new ArrayList<Map<String, String>>();

	Map<String, String> map0 = new HashMap<String, String>();
	map0.put("name", "洗牙");
	datasource.add(map0);

	Map<String, String> map1 = new HashMap<String, String>();
	map1.put("name", "补牙");
	datasource.add(map1);

	Map<String, String> map2 = new HashMap<String, String>();
	map2.put("name", "镶牙");
	datasource.add(map2);

	Map<String, String> map3 = new HashMap<String, String>();
	map3.put("name", "疼痛");
	datasource.add(map3);

	Map<String, String> map4 = new HashMap<String, String>();
	map4.put("name", "牙齿美容");
	datasource.add(map4);

	Map<String, String> map5 = new HashMap<String, String>();
	map5.put("name", "牙龈出血");
	datasource.add(map5);

	Map<String, String> map6 = new HashMap<String, String>();
	map6.put("name", "牙齿松动");
	datasource.add(map6);

	Map<String, String> map7 = new HashMap<String, String>();
	map7.put("name", "牙齿正畸");
	datasource.add(map7);

	Map<String, String> map8 = new HashMap<String, String>();
	map8.put("name", "拔牙");
	datasource.add(map8);

	Map<String, String> map9 = new HashMap<String, String>();
	map9.put("name", "牙齿折裂");
	datasource.add(map9);

	SimpleAdapter adapter = new SimpleAdapter(this, datasource,
		R.layout.view_main3_menu1_item, new String[] { "name" },
		new int[] { R.id.vmmi_txt_name });

	mListViewMenu.setAdapter(adapter);

	/**
	 * 症状
	 * */

	mLayoutCondition = (ViewGroup) findViewById(R.id.main2_layout_condition);
	mWebViewContent = (WebView) findViewById(R.id.main2_webview_content);

	for (int i = 0; i < 6; i++) {
	    Button btnCondition = new Button(this);
	    btnCondition.setText("症状" + i);
	    mLayoutCondition.addView(btnCondition, new LayoutParams(
		    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

	    final int index = i;
	    btnCondition.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
		    // TODO Auto-generated method stub
		    mWebViewContent
			    .loadUrl("http://www.baidu.com/s?bs=1&f=8&rsv_bp=1&rsv_spt=3&wd="
				    + index + "&inputT=0");
		}
	    });
	}
	mWebViewContent.loadUrl("http://www.baidu.com");
	
	Button btnReturn = (Button) findViewById(R.id.main2_btn_return);
	btnReturn.setOnClickListener(new OnClickListener() {

	    @Override
	    public void onClick(View v) {
		// TODO Auto-generated method stub
		ActivityView2.this.finish();
	    }
	});

    }
}
